/*
 * @lc app=leetcode.cn id=905 lang=cpp
 *
 * [905] 按奇偶排序数组
 */

// @lc code=start
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
    vector<int> sortArrayByParity(vector<int>& nums) {
        vector<int> ans(nums.size());
        int l = 0, r = ans.size() - 1;
        for(auto& n : nums)
        {
            if(n & 1) ans[r--] = n;
            else ans[l++] = n;
        }
        return ans;
    }
};
// @lc code=end

